
<#include "/head.ftl" />
<div id="pg_margins">
<div id="col1"><#include "/sidebar.ftl" /></div>
<div id="col2">

<div class="location">SEO管理</div>

<div class="massaction"></div>

<form class="form-horizontal form" id="searchForm">
	<input name="sid" type="hidden" value="${sid}"/>
</form>

<div style="float:left;width:100%;">
	<table id="listTable" class="table table-striped table-bordered table-hover bd_c_1" cellpadding="0" cellspacing="0"></table>
</div>

</div>			
</div>
<script>
    var $table = $('#listTable');
    var $param = {};

    $(function () {
        // bootstrap table初始化
        $param = {
            url: '/seo/list',
            striped: false,
            pagination: true,
            paginationLoop: false,
            sidePagination: 'server',
            smartDisplay: false,
            striped: true,
            idField: 'id',
            sortName: 'id',
            sortOrder: 'desc',
            //得到查询的参数
            queryParams: function (params) {
                var temp = $("#searchForm").serializeJsonObject();
                temp["limit"] = params.limit;
                temp["offset"] = params.offset;
                return temp;
            },
            onLoadSuccess: function() {
            	$('#listTable thead tr').attr("class", "headings");
            },
            columns: [
                {field: 'id', title: '编号', align: 'center', valign: 'middle'},
                {field: 'sid', title: '网站名称', align: 'center', valign: 'middle'},
                {field: 'alexa', title: 'ALEXA排名', align: 'center', valign: 'middle'},
                {field: 'baidu', title: '百度索引数', align: 'center', valign: 'middle'},
                {field: 'google', title: '谷歌索引数', align: 'center', valign: 'middle'},
                {field: 'pr', title: '谷歌PR值', align: 'center', valign: 'middle'},
                {
                    field: 'id',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: 'operateFormatter',
                    clickToSelect: false
                }
            ]
        };
        $table.bootstrapTable($param);
    });

    function operateFormatter(value, row, index) {
        var action = [];
        action.push('<a href="javascript:;" onclick="refreshSeo(' + row.id + ')">刷新</a>');
        return action.join('&nbsp;&nbsp;|&nbsp;&nbsp;');
    }

    function searchSeo() {
        $table.bootstrapTable('destroy').bootstrapTable($param);
    }
    
    function refreshSeo(id) {
        confirm("确认刷新该网站SEO数据？", function() {
            $.ajax({
                url: "/seo/refresh?id=" + id,
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(res) {
                    if (res.code != "0200") {
                        showMsgFail(res.message ? res.message : "请求失败");
                        return false;
                    }
                    searchSeo();
                },
                error: function(e) {
                    showMsgFail("请求失败");
                }
            });
        });
    }
</script>
<#include "/foot.ftl" />
